import { http } from "@/utils/http";

/** 查询参数 */
export interface BotQuestionQuery extends BasePageQuery {
  question?: string;
  createUser?: string;
}

/** 页面响应结构 */
export interface BotQuestionPageResponse {
  id: number;
  question: string;
  answer: string;
  createUser: string;
  createTime: string;
}

/** 获取问答列表分页 */
export function getBotQuestionListApi(params: BotQuestionQuery) {
  return http.request<ResponseData<PageDTO<BotQuestionPageResponse>>>(
    "get",
    "/bot/bot-question/list",
    {
      params
    }
  );
}

/** 导出问答 Excel */
export const exportBotQuestionExcelApi = (
  params: BotQuestionQuery,
  fileName: string
) => {
  return http.download("/bot/bot-question/excel", fileName, {
    params
  });
};

/** 删除问答记录 */
export const deleteBotQuestionApi = (data: Array<number>) => {
  return http.request<ResponseData<void>>("delete", "/bot/bot-question", {
    params: {
      ids: data.toString()
    }
  });
};

/** 添加问答记录 */
export interface AddBotQuestionCommand {
  question: string;
  answer: string;
  createUser?: string;
}

export const addBotQuestionApi = (data: AddBotQuestionCommand) => {
  return http.request<ResponseData<void>>("post", "/bot/bot-question", {
    data
  });
};

/** 修改问答记录 */
export interface UpdateBotQuestionCommand extends AddBotQuestionCommand {
  id: number;
}

export const updateBotQuestionApi = (data: UpdateBotQuestionCommand) => {
  return http.request<ResponseData<void>>("put", "/bot/bot-question", {
    data
  });
};
